#coding:utf-8
from haystack import indexes
from lovewith.share.models import Post, AttachTag


class PostIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    post_date = indexes.DateTimeField(model_attr='post_date')

    def get_model(self):
        return Post

    def index_queryset(self, using=None):
        """Used when the entire index for model is updated."""
        return self.get_model().objects.all()


# class AttachTagIndex(indexes.SearchIndex, indexes.Indexable):
#     text = indexes.CharField(document=True, use_template=True)
#     tagname = indexes.CharField(model_attr='tagname')
#
#     def get_model(self):
#         return AttachTag
#
#     def index_queryset(self, using=None):
#         """Used when the entire index for model is updated."""
#         return self.get_model().objects.all()